package com.itheima.health.mq;


import com.itheima.health.utils.aliyunDX.SendSms;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Map;

@RestController
public class SendMesaaqe {
    @RabbitListener(queues = "/czjk")//  注意只需要 队列名称一致即可！
    public void receive(Map map, Channel channel, Message message) throws IOException {
        //会话唯一ID
        long deliveryTag = message.getMessageProperties().getDeliveryTag();
        try {
            String telephone = (String) map.get("telephone");
            String cod = (String) map.get("cod");
            System.out.println("telephone:" + telephone + "--cod:" + cod);

            //调用阿里云
            //SendSms.registerSendCode(telephone,cod);



        } catch (Exception e) {
            channel.basicNack(deliveryTag, false, true);
        }
    }
}
